package com.wang;

import java.security.Key;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ProjectName: untitled
 * @Titile: HashMapPractice
 * @Author: 王亦凡1
 * @Description: TODO
 */
public class HashMapPractice {
    public static void main(String[] args) {
        List<String> scProvince= new ArrayList<>();
        scProvince.add("成都");
        scProvince.add("达州");
        scProvince.add("巴中");
        scProvince.add("宜宾");
        scProvince.add("绵阳");
        List<String> hnProvince= new ArrayList<>();
        hnProvince.add("长沙");
        hnProvince.add("张家界");
        hnProvince.add("怀化");
        hnProvince.add("荆州");
        hnProvince.add("益阳");

        Map<String,List<String>>map=new HashMap<>();
        map.put("四川省", scProvince);
        map.put("湖南省", hnProvince);
        System.out.println("四川省"+scProvince);
        System.out.println("湖南省"+hnProvince);

    }
    public static void printMap(Map<String, List<String>> map) {
        map.forEach((key,value)->
        {   StringBuilder sb =new StringBuilder();
            value.forEach(city->{
                sb.append(city+",");
            });
            //把sb后面的逗号去掉
            sb.deleteCharAt(sb.length() - 1);
            String result=key+"="+sb;
            System.out.println(result);
        });

    }
}
